home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Applications
/
PICSee Dust 1.01
/
Quaternary Source
/
GraphicsBufferPriv.h
< prev
next >
Wrap
Text File
|
1995-11-24
|
6KB
|
221 lines
#ifndef GRAPHICSBUFFERPRIV_H_
#define GRAPHICSBUFFERPRIV_H_
/*
GraphicsBufferPriv.h file, Macintosh platform version.
by Hiep Dam
Version 4.0
Last update: Sept 1995
This is the header file specific and private to the Macintosh platform
implementation of GraphicsBuffer. Do not use this file in your own
applications; use GraphicsBuffer.h instead.
*/
// ---------------------------------------------------------------------------
#define NDEBUG
#include "assert_mac.h"
#ifndef __PALETTES__
#include <Palettes.h>
#endif
#ifndef __QDOFFSCREEN__
#include <QDOffscreen.h>
#endif
#ifndef CP_UTILS_H_
#include "CP_Utils.h"
#endif
// ---------------------------------------------------------------------------
typedef struct {
short bufferType; // kGraphicsBuffer, kGraphicsEnvironment,
// or kVideoMemoryBuffer
short bufferFlushedTopLeft; // true if topleft of global rect is (0,0)
short bufferCached;
short bufferDepth;
GWorldPtr gworld; // GWorld itself
// (if kVideoMemoryBuffer, this is nil).
Rect localBounds; // Bounds of the gworld, in local coords.
Rect globBounds; // Bounds, in global coords.
Rect videoBounds; // Used only if type == kVideoMemoryBuffer
PixMapHandle pixmap;
WindowPtr window;
unsigned long realRowBytes; // (**pixmap).rowBytes & 0x7FFF.
unsigned long rowBytesDiv4; // stripRowBytes / 4.
unsigned long rowBytesDiv2;
unsigned long *rowAddressOffsets; // Array of pre-calculated
// rowByte offsets.
} GraphicsBuffer;
typedef GraphicsBuffer *GraphicsBufferPrivPtr;
// ---------------------------------------------------------------------------
/*
Some useful typedef and defines
*/
typedef unsigned char *OnePixelPtr_8bit,
*TwoPixelsPtr_4bit;
typedef unsigned short *PixelPtr_16bit,
*TwoPixelsPtr_8bit,
*FourPixelsPtr_4bit;
typedef unsigned long *TwoPixelsPtr_16bit,
*FourPixelsPtr_8bit,
*EightPixelsPtr_4bit;
typedef double *FourPixelsPtr_16bit,
*EightPixelsPtr_8bit;
// ---------------------------------------------------------------------------
#define PtrCopy(s, d) (*(d)++ = *(s)++)
//#define PtrMaskCopy(s, d, m) *(d) &= *(m)++; *(d)++ |= *(s)++
#define PtrMaskCopy(s, d, m) (*(d)++ = (*(d) & *(m)++) | *(s)++)
// Some "traditionally faster" shortcuts
#define USE_FASTMATH
#if defined(USE_FASTMATH)
#define FASTDIV2(n) ((n) >> 1L)
#define FASTDIV4(n) ((n) >> 2L)
#define FASTDIV8(n) ((n) >> 3L)
#define FASTMULT2(n) ((n) << 1L)
#define FASTMULT4(n) ((n) << 2L)
#define FASTMULT8(n) ((n) << 3L)
#define FASTMOD2(n) ((n) & 1L)
#define FASTMOD4(n) ((n) & 3L)
#else
#define FASTDIV2(n) ((n)/2)
#define FASTDIV4(n) ((n)/4)
#define FASTDIV8(n) ((n)/8)
#define FASTMULT2(n) ((n)*2)
#define FASTMULT4(n) ((n)*4)
#define FASTMULT8(n) ((n)*8)
#define FASTMOD2(n) ((n)%2)
#define FASTMOD4(n) ((n)%4)
#endif // USE_FASTMATH
// ---------------------------------------------------------------------------
/* Code switches */
// Comment out if you only want to use the C versions, otherwise
// the routines with the 680x0 asm versions will be used.
#define USE_ASM68K
// Turn off asm usage if compiling for PowerPC...
#if defined(powerc) || defined(__powerc) || defined(POWERPC)
#undef USE_ASM68K
#endif
/*
Comment out if you don't need clipping (you're sure your rect won't
be out of bounds of the pixmap's boundaries; if so you'll be writing
to other areas of memory, a dangerous situation).
Removing the checks should improve the speed however.
*/
#define BLIT_CLIPPING
/*
This does automatic offseting if your destination graphicsbuffer
(kVideoMemoryBuffer) is not flushed topleft at 0,0. You'll want
to leave this in...
*/
#define BLIT_OFFSET
/*
Comment out if you're sure the rects you pass to the blitters
aren't empty. If they are, the blitters will loop forever!
*/
#define BLIT_CHECKEMPTY
// ---------------------------------------------------------------------------
#ifdef BLIT_CLIPPING
#define BlitClipBounds(srcRect, destRect, buffer) \
if (destRect.top < buffer->localBounds.top) { \
srcRect.top += buffer->localBounds.top - destRect.top; \
destRect.top = buffer->localBounds.top; \
if (destRect.top >= destRect.bottom) return; \
} \
else if (destRect.bottom > buffer->localBounds.bottom) { \
srcRect.bottom -= destRect.bottom - buffer->localBounds.bottom; \
destRect.bottom = buffer->localBounds.bottom; \
if (destRect.bottom <= destRect.top) return; \
} \
if (destRect.left < buffer->localBounds.left) { \
srcRect.left += buffer->localBounds.left - destRect.left; \
destRect.left = buffer->localBounds.left; \
if (destRect.left >= destRect.right) return; \
} \
else if (destRect.right > buffer->localBounds.right) { \
srcRect.right -= destRect.right - buffer->localBounds.right; \
destRect.right = buffer->localBounds.right; \
if (destRect.right <= destRect.left ) return; \
}
#else
#define BlitClipBounds(srcRect, destRect, buffer)
#endif
#ifdef BLIT_OFFSET
#define BlitOffset(destRect, buffer) \
if (buffer->bufferType == kVideoMemoryBuffer && \
buffer->bufferFlushedTopLeft == false) { \
FastOffsetRect(destRect, buffer->globBounds.left, buffer->globBounds.top);\
}
#else
#define BlitOffset(destRect, buffer)
#endif
#ifdef BLIT_CHECKEMPTY
#define CheckEmptyRect(destRect) \
if (destRect.right <= destRect.left || \
destRect.bottom <= destRect.top) return
#else
#define CheckEmptyRect(destRect)
#endif
// ---------------------------------------------------------------------------
// Related to the blitters only.
extern SignedByte gMMUMode;
extern Boolean gNotIn32Mode;
/*
Blitting info; only routines that have both a C and 680x0 asm version
uses this structure. Eventually I'll have all the pixel copying routines
using this. This structure is long-word aligned for maximum efficiency
on both 68K and PPC architectures.
*/
typedef struct {
CP_ULong widthChunksToCopy;
CP_ULong srcRowOffset;
CP_ULong destRowOffset;
CP_ULong rowsToCopy;
CP_ULong destMem;
CP_ULong srcMem; // typecast to char*, short*, or long*
} BlitInfo;
extern BlitInfo mBlitInfo;
#endif // GRAPHICSBUFFERPRIV_H_